package com.example.userdemo.config;


import org.apache.kafka.common.protocol.types.Field;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

@Configuration
public class JedisConfig {

    @Value("${spring.redis.host}")
    private String host;

    @Value("${spring.redis.port}")
    private int port;

    @Bean
    public Jedis getJedis(){
        try {
            JedisPool jedisPool = new JedisPool(host, port);
            return jedisPool.getResource();
        }catch (Exception e){
            return null;
        }
    }
}
